//
//  UIView+IBExtension.swift
//  weibobbaj
//
//  Created by Tiffany宝 on 16/4/16.
//  Copyright © 2016年 Tiffany. All rights reserved.
//

import UIKit

extension UIView{
    
    // MARK: - borderWidth
    @IBInspectable var borderWidth: CGFloat{
        
        get{
            
            return self.layer.borderWidth
        }
        
        set{
            
            self.layer.borderWidth = newValue
        }
    }
    
    // MARK: - borderColor
    @IBInspectable var borderColor: UIColor?{ //UIColor?
        
        get{
            if let bc = self.layer.borderColor{
                
                // 如何把 CGColor 转成 UIColor
                return UIColor(CGColor: bc)
            }
            return nil
        }
        
        set{
            
            // borderColor?
            self.layer.borderColor = newValue?.CGColor
        }
    }
    
    // MARK: - cornerRadius
    @IBInspectable var cornerRadius:CGFloat{
        
        get{
            
            return self.layer.cornerRadius
        }
        set{
            
            self.layer.cornerRadius = newValue
            self.layer.masksToBounds = newValue > 0
        }
    }
    
}